inherited fmServicePeopleLink: TfmServicePeopleLink
  Left = 121
  Top = 129
  Width = 608
  Height = 450
  Caption = 'fmServicePeopleLink'
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  object Label3: TLabel [0]
    Left = 16
    Top = 316
    Width = 35
    Height = 13
    Caption = #1059#1089#1083#1091#1075#1072
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clGray
    Font.Height = -11
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentFont = False
  end
  inherited sbBottom: TStatusBar
    Top = 389
    Width = 600
  end
  inherited Panel1: TPanel
    Width = 600
    inherited BitBtn1: TBitBtn
      Left = 430
    end
    inherited BitBtn2: TBitBtn
      Left = 518
    end
  end
  object ToolBar2: TToolBar [3]
    Left = 0
    Top = 45
    Width = 600
    AutoSize = True
    BorderWidth = 2
    EdgeInner = esNone
    EdgeOuter = esNone
    Images = DMInv.ilActive
    TabOrder = 2
    TabStop = True
    Transparent = True
    object tbAddLink: TToolButton
      Left = 0
      Top = 2
      Hint = #1044#1086#1073#1072#1074#1080#1090#1100' '#1089#1074#1103#1079#1100
      ImageIndex = 30
      ParentShowHint = False
      ShowHint = True
      OnClick = tbAddLinkClick
    end
    object tbDelLink: TToolButton
      Left = 23
      Top = 2
      Hint = #1059#1076#1072#1083#1080#1090#1100' '#1089#1074#1103#1079#1100
      ImageIndex = 29
      ParentShowHint = False
      ShowHint = True
      OnClick = tbDelLinkClick
    end
  end
  object dbgSPRel: TcxGrid [4]
    Left = 0
    Top = 77
    Width = 600
    Height = 236
    Align = alTop
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -13
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentFont = False
    TabOrder = 3
    LookAndFeel.Kind = lfStandard
    object tvSPRel: TcxGridDBTableView
      NavigatorButtons.ConfirmDelete = False
      NavigatorButtons.PriorPage.Visible = True
      NavigatorButtons.Next.Visible = True
      NavigatorButtons.Insert.Visible = True
      NavigatorButtons.Append.Visible = False
      NavigatorButtons.Edit.Visible = False
      NavigatorButtons.Post.Visible = True
      NavigatorButtons.Cancel.Visible = False
      NavigatorButtons.Refresh.Visible = False
      NavigatorButtons.SaveBookmark.Visible = False
      NavigatorButtons.GotoBookmark.Visible = False
      NavigatorButtons.Filter.Visible = False
      DataController.DataSource = dlgDS
      DataController.Summary.DefaultGroupSummaryItems = <>
      DataController.Summary.FooterSummaryItems = <
        item
          Kind = skCount
          FieldName = 'PID'
        end>
      DataController.Summary.SummaryGroups = <>
      OptionsBehavior.CellHints = True
      OptionsCustomize.ColumnFiltering = False
      OptionsData.Appending = True
      OptionsData.CancelOnExit = False
      OptionsView.CellEndEllipsis = True
      OptionsView.NoDataToDisplayInfoText = '<'#1053#1077#1090' '#1076#1072#1085#1085#1099#1093'>'
      OptionsView.CellAutoHeight = True
      OptionsView.CellTextMaxLineCount = 1
      OptionsView.ColumnAutoWidth = True
      OptionsView.Footer = True
      OptionsView.GroupByBox = False
      OptionsView.HeaderEndEllipsis = True
      OptionsView.Indicator = True
      Preview.Visible = True
      Styles.Header = DMInv.cxSiniyText
      object tvSPRelColumn1: TcxGridDBColumn
        Caption = #8470
        OnGetDataText = tvSPRelColumn1GetDataText
        Options.Editing = False
        Options.Filtering = False
        Options.Moving = False
        Options.Sorting = False
        Width = 20
      end
      object tvSPRelPID: TcxGridDBColumn
        DataBinding.FieldName = 'PID'
        PropertiesClassName = 'TcxLookupComboBoxProperties'
        Properties.KeyFieldNames = 'PID'
        Properties.ListColumns = <
          item
            FieldName = 'PP'
          end>
        Properties.ListSource = dsSotr
        Width = 196
      end
      object tvSPRelSDNAME: TcxGridDBColumn
        DataBinding.FieldName = 'SDNAME'
        Width = 368
      end
    end
    object cxGridLevel2: TcxGridLevel
      GridView = tvSPRel
    end
  end
  object ltvUsluga: TdxDBLookupTreeView [5]
    Left = 12
    Top = 334
    Width = 297
    Height = 24
    CanSelectParents = False
    DropDownRows = 25
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clGray
    Font.Height = -13
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentColor = False
    ParentFont = False
    TabOrder = 4
    TabStop = True
    Text = 'ltvUsluga'
    TreeViewColor = clWindow
    TreeViewCursor = crDefault
    TreeViewFont.Charset = DEFAULT_CHARSET
    TreeViewFont.Color = clWindowText
    TreeViewFont.Height = -11
    TreeViewFont.Name = 'MS Sans Serif'
    TreeViewFont.Style = []
    TreeViewIndent = 19
    TreeViewReadOnly = False
    TreeViewShowButtons = True
    TreeViewShowHint = False
    TreeViewShowLines = True
    TreeViewShowRoot = True
    TreeViewSortType = stNone
    TreeViewStateImages = DMInv.ilBJTree
    OnCloseUp = ltvUslugaCloseUp
    DisplayField = 'SDNAME'
    DividedChar = '.'
    ImageIndexField = 'SDISDELETE'
    ListSource = dsSD
    KeyField = 'SDID'
    ListField = 'SDNAME'
    Options = [trDBCanDelete, trDBConfirmDelete, trCanDBNavigate, trSmartRecordCopy, trCheckHasChildren]
    ParentField = 'SDPARID'
    RootValue = 0
    TextStyle = tvtsShort
    DataField = 'SDID'
    DataSource = dlgDS
  end
  inherited dlgDS: TDataSource
    DataSet = qSPRel
  end
  object qSPRel: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    CachedUpdates = True
    SQL.Strings = (
      'select SPR.*, SD.SDNAME'
      'from SERVICE_PEOPLE_REL SPR'
      'INNER join SYS_DIC SD on SD.SDID = SPR.SDID')
    UpdateObject = IBUpdateSQL1
    Left = 296
    Top = 16
    object qSPRelPID: TIntegerField
      FieldName = 'PID'
      Origin = '"SERVICE_PEOPLE_REL"."PID"'
    end
    object qSPRelSDID: TIntegerField
      FieldName = 'SDID'
      Origin = '"SERVICE_PEOPLE_REL"."SDID"'
    end
    object qSPRelSDNAME: TIBStringField
      FieldName = 'SDNAME'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
  end
  object IBUpdateSQL1: TIBUpdateSQL
    RefreshSQL.Strings = (
      'Select '
      '  PID,'
      '  SDID'
      'from SERVICE_PEOPLE_REL '
      'where'
      '  PID = :PID and'
      '  SDID = :SDID')
    ModifySQL.Strings = (
      'update SERVICE_PEOPLE_REL'
      'set'
      '  PID = :PID,'
      '  SDID = :SDID'
      'where'
      '  PID = :OLD_PID and'
      '  SDID = :OLD_SDID')
    InsertSQL.Strings = (
      'insert into SERVICE_PEOPLE_REL'
      '  (PID, SDID)'
      'values'
      '  (:PID, :SDID)')
    DeleteSQL.Strings = (
      'delete from SERVICE_PEOPLE_REL'
      'where'
      '  PID = :OLD_PID and'
      '  SDID = :OLD_SDID')
    Left = 328
    Top = 16
  end
  object qSD: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT t1.*, SD1.SDISDELETE'
      'FROM'
      '('
      'WITH   recursive'
      '   tree (SDNAME, SDID, SDPARID, o)'
      
        '   AS (SELECT SD.SDNAME, SD.SDID, sd.SDPARID, CAST('#39#39' AS VARCHAR' +
        '(2048)) AS o FROM SYS_DIC SD'
      '      WHERE sd.SDPARID  = 14'
      '      UNION ALL'
      '      SELECT SD1.SDNAME, SD1.SDID, sd1.SDPARID, '#39' '#39' || o'
      ''
      '      FROM SYS_DIC SD1'
      '          INNER JOIN tree t '
      '           ON t.sdid = sd1.SDPARID)'
      ' SELECT  o || SDNAME AS SDNAME, SDID, SDPARID FROM tree t'
      ') AS t1'
      'INNER JOIN SYS_DIC sd1 ON sd1.SDID = t1.sdid'
      'order by 1'
      '')
    GeneratorField.Field = 'SDID'
    Left = 208
    Top = 328
    object qSDSDID: TIntegerField
      FieldName = 'SDID'
      ProviderFlags = []
    end
    object qSDSDPARID: TIntegerField
      FieldName = 'SDPARID'
      ProviderFlags = []
    end
    object qSDSDNAME: TIBStringField
      DisplayLabel = #1069#1083#1077#1084#1077#1085#1090
      FieldName = 'SDNAME'
      ProviderFlags = []
      Size = 2304
    end
    object qSDSDISDELETE: TIntegerField
      DisplayLabel = #1059#1076#1072#1083#1080#1090#1100'?'
      FieldName = 'SDISDELETE'
      Origin = '"SYS_DIC"."SDISDELETE"'
    end
  end
  object dsSD: TDataSource
    DataSet = qSD
    Left = 179
    Top = 334
  end
  object qSotr: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      
        'SELECT P.PID, (COALESCE(P.PLASTNAME,'#39' '#39')||'#39' '#39'||COALESCE(P.PNAME,' +
        #39' '#39')||'#39' '#39'||COALESCE(P.PPATRONYMIC,'#39' '#39')) AS PP,'
      '    SD.SDNAME, PS.SDID'
      'FROM PEOPLE P'
      'INNER JOIN P_STATUS PS ON PS.PID = P.PID'
      'INNER JOIN SYS_DIC SD ON SD.SDID = PS.SDID'
      'INNER JOIN'
      '('
      'SELECT t1.sdid'
      'FROM'
      '('
      'WITH   recursive'
      '   tree (SDNAME, SDID, SDPARID, o)'
      
        '   AS (SELECT SD.SDNAME, SD.SDID, sd.SDPARID, CAST('#39#39' AS VARCHAR' +
        '(2048)) AS o FROM SYS_DIC SD'
      '      WHERE sd.SDPARID  = 1470'
      '      UNION ALL'
      '      SELECT SD1.SDNAME, SD1.SDID, sd1.SDPARID, '#39' '#39' || o'
      ''
      '      FROM SYS_DIC SD1'
      '          INNER JOIN tree t '
      '           ON t.sdid = sd1.SDPARID)'
      ' SELECT  o || SDNAME AS SDNAME, SDID, SDPARID FROM tree t'
      ') AS t1'
      'WHERE t1.sdid <> 1783'
      ') as sotr on sotr.sdid = ps.SDID'
      'WHERE P.PISDELETE IS NULL'
      'UNION'
      'SELECT FIRST 1 NULL AS PID, NULL AS PP,'
      '    NULL AS SDNAME, NULL AS SDID'
      'FROM PEOPLE P'
      'ORDER BY 2')
    Left = 352
    Top = 328
    object qSotrPID: TIntegerField
      FieldName = 'PID'
      Origin = '"PEOPLE"."PID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
    end
    object qSotrPP: TIBStringField
      FieldName = 'PP'
      ProviderFlags = []
      Size = 767
    end
    object qSotrSDNAME: TIBStringField
      FieldName = 'SDNAME'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
    object qSotrSDID: TIntegerField
      FieldName = 'SDID'
      Origin = '"P_STATUS"."SDID"'
    end
  end
  object dsSotr: TDataSource
    DataSet = qSotr
    Left = 320
    Top = 328
  end
end
